﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLToolkit.Data;
using System.Data;

namespace Bai2
{
    public class RepositoryCustomer
    {
        private DbManager db = new DbManager("NorthwindConnectioString");

        public DataSet GetAll()
        {
            using (db)
            {
                return db.SetCommand("SELECT * FROM Customers WHERE 1 = 1;").ExecuteDataSet();
            }
        }

        public Customer Details(string custId)
        {
            using (db)
            {
                return db.SetCommand("Customer_Details", db.Parameter("@CustomerID", custId)).ExecuteObject<Customer>();
            }
        }
        public int Create(Customer c)
        {
            using (db)
            {
                return db.SetSpCommand("", db.CreateParameters(c)).ExecuteNonQuery();
            }
        }
    }
}